<template>
    <div class="main">
        <div class="content">
            <div class="breadcrumb">
                <div class="title">
                    <span class="">排单数量：</span>
                    <span class="num">{{total}}</span>
                    <span class="h1">排单金额：</span>
                    <span class="num">{{amount_all}}</span>
                </div>
            </div>
            <div class="cont">
                <div class="title">
                    <div class="left">
                        <!-- <div class="item select">
                            <el-select v-model="type" placeholder="支付方式">
                                <el-option label="分类" :value="1"></el-option>
                                <el-option label="分类1" :value="2"></el-option>
                            </el-select>
                        </div>
                        <div class="item select">
                            <el-select v-model="type" placeholder="不按时间">
                                <el-option label="分类" :value="1"></el-option>
                                <el-option label="分类1" :value="2"></el-option>
                            </el-select>
                        </div> -->
                        <div class="item ">
                            <el-date-picker
                            v-model="date"
                            type="daterange"
                            align="right"
                            unlink-panels
                            format="yyyy 年 MM 月 dd 日"
                            value-format="yyyy-MM-dd"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            :picker-options="pickerOptions">
                            </el-date-picker>
                        </div>
                        <!-- <div class="item select">
                            <el-select v-model="type" placeholder="订单号">
                                <el-option label="分类" :value="1"></el-option>
                                <el-option label="分类1" :value="2"></el-option>
                            </el-select>
                        </div> -->
                        <div class="item ">
                            <el-input placeholder="搜索订单号" v-model="ordersn"></el-input>
                        </div>
                        <div class="item ">
                            <el-input placeholder="搜索手机号" v-model="mobole"></el-input>
                        </div>
                    </div>
                    <div class="right">
                        <!-- <div class="item select">
                            <el-select v-model="type" placeholder="全部订单">
                                <el-option label="分类" :value="1"></el-option>
                                <el-option label="分类1" :value="2"></el-option>
                            </el-select>
                        </div> -->
                        <div class="item">
                            <el-button @click="search" type="primary">搜索</el-button>
                        </div>
                        <div class="item">
                            <el-button type="success">导出</el-button>
                        </div>
                    </div>
                </div>
                <div class="table" v-loading="loading">
                    <el-row>
                        <el-col :span="6">商家名称</el-col>
                        <el-col :span="4">用户信息</el-col>
                        <el-col :span="4">排队进度</el-col>
                        <el-col :span="3">消费金额</el-col>
                        <el-col :span="3">兑换积分</el-col>
                        <el-col :span="4">排单编号</el-col>
                    </el-row>
                    <div class="item" v-for="item in tableData" :key="item.id">
                        <div class="title">
                            <div class="left">
                                <el-tag>{{item.status==0?'待排':item.status==1?'正在排':item.status==-1?'兑换积分':'已拍完'}}</el-tag>
                                <strong>{{item.createtime}}</strong>
                                <span class="order_num">订单编号：{{item.ordersn}}</span>
                            </div>
                            <div class="right">备注</div>
                        </div>
                        <div class="btm">
                            <el-row type="flex">
                                <el-col :span="6">
                                    <div class="goods_name">
                                        <div class="img">
                                            <img :src="item.shop_logo" alt="" srcset="">
                                        </div>
                                        <div class="title">{{item.shopname}}</div>
                                    </div>
                                </el-col>
                                <el-col :span="4">
                                    <div class="item">
                                        <p>{{item.nickname}}</p>
                                        <p>{{item.mobile}}</p>
                                    </div>
                                </el-col>
                                <el-col :span="4">
                                    <div class="item"><el-progress :percentage="item.schedule*100"></el-progress></div>
                                </el-col>
                                <el-col :span="3">
                                    <div class="item">￥{{item.price}}</div>
                                </el-col>
                                <el-col :span="3">
                                    <div class="item">
                                        <span class="yes" v-show="item.status==-1">是</span>
                                        <span class="no" v-show="item.status!=-1">否</span>
                                    </div>
                                </el-col>
                                <el-col :span="4">
                                    <div class="item">{{item.ordersn}}</div>
                                </el-col>
                            </el-row>
                        </div>
                    </div>
                    
                </div>
                <div class="page">
                    <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[6, 12, 48, 96]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
                    </el-pagination>
                </div>
            </div>
        </div>
        
    </div>
</template>
<script>
export default {
    data(){
        return{
            loading:false,
            tableData:[],
            amount_all:0,//排单金额
            ordersn:'',//订单号
            mobole:'',//手机号
            currentPage:1,//当前分页
            pageSize:6,//分页数量
            total:0,//数据总数
            type:'',
            date:'',
            pickerOptions: {
                shortcuts: [{
                    text: '最近一周',
                    onClick(picker) {
                    const end = new Date();
                    const start = new Date();
                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                    picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近一个月',
                    onClick(picker) {
                    const end = new Date();
                    const start = new Date();
                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                    picker.$emit('pick', [start, end]);
                    }
                }, {
                    text: '最近三个月',
                    onClick(picker) {
                    const end = new Date();
                    const start = new Date();
                    start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                    picker.$emit('pick', [start, end]);
                    }
                }]
            },
        }
    },
    mounted(){
        this.getList()
    },
    computed:{
        
    },
    methods:{
        //搜索
        search(){
            this.currentPage = 1
            this.getList()
        },
        //当前页面数据量改变
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.pageSize = val
             this.currentPage = 1
            this.getList()
        },
        //翻页
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.currentPage = val
            this.getList()
        },
        //编辑
        handleEdit(index, row) {
            console.log(index, row);
        },
        //删除
        handleDelete(index, row) {
            console.log(index, row);
        },
        //当前选中项
        handleSelectionChange(val) {
            console.log(val);
        },
        //获取列表
        async getList(){
            let starttime=''
            let endtime=''
            if (this.date) {
                starttime = this.date[0]
                endtime = this.date[1]
            }
            let req = new FormData()
            req.append('page',this.currentPage)
            req.append('pagesize',this.pageSize)
            req.append('starttime',starttime)
            req.append('endtime',endtime)
            req.append('ordersn',this.ordersn)
            req.append('mobole',this.mobole)
            this.loading = true
            let{data:{status,result}} = await this.$http.post(this.$api.lineup_gongpai_index,req)
            this.loading = false
            if (status == 0) {
                this.tableData = result.list
                this.amount_all = result.amount_all
                this.total = Number(result.total)
            }
        },
    }
}
</script>
<style lang="scss" scoped>
    .main{
        display: flex;
        .content{
            padding: 20px;
            width: 100%;
            .breadcrumb{
                .title{
                    border-left: 2px solid rgb(0, 140, 255);
                    line-height: 16px;
                    padding-left: 5px;
                    .h1{
                        margin-left: 10px;
                    }
                    .num{
                        color: red;
                    }
                }
            }
            .cont{
                padding: 20px 30px;
                background-color: #ffffff;
                margin-top: 15px;
                box-sizing: border-box;
                .title{
                    display: flex;
                    justify-content: space-between;
                    width: 100%;
                    .left,.right{
                        display: flex;
                        justify-content: flex-end;
                        .item{
                            margin: 0 5px;
                        }
                        .select{
                            width: 120px;
                        }
                    }
                }
                .table{
                    .el-row{
                        padding: 10px 15px;
                        margin-top: 20px;
                        background-color: #f0f0f0;
                        >div{
                            text-align: center;
                        }
                        >div:first-child{
                            text-align: left;
                        }
                    }
                    .item{
                        margin-top: 20px;
                        .title{
                            padding: 10px 15px;
                            background-color: #f0f0f0;
                            box-sizing: border-box;
                            display: flex;
                            justify-content: space-between;
                            align-items: center;
                            font-size: 12px;
                            .left{
                                display: flex;
                                align-items: center;
                                strong{
                                    margin: 0 10px;
                                }
                                .order_num{
                                    color: #666;
                                }
                            }
                        }
                        .el-row{
                            background-color: #ffffff;
                            margin-top: 0;
                            padding: 0;
                            .goods_name{
                                display: flex;
                                .img{
                                    border: 1px solid #f0f0f0;
                                    width: 50px;
                                    height: 50px;
                                    padding:5px;
                                    img{
                                        width: 50px;
                                        height: 50px;
                                        
                                    }
                                }
                                .title{
                                    width:calc(100% - 80px);
                                    background-color: #ffffff;
                                }
                            }
                            .el-col{
                                border-right: 1px solid #f0f0f0;
                                padding: 10px 20px;
                                border-bottom: 1px solid #f0f0f0;
                            }
                            .el-col:first-child{
                                border-left: 1px solid #f0f0f0;
                            }
                            .item{
                                font-size: 12px;
                                .yes{
                                    padding: 5px 20px;
                                    background-color: rgb(0, 204, 255);
                                    color: #ffffff;
                                }
                                .no{
                                   padding: 5px 20px;
                                   background-color: #666;
                                   color: #ffffff;
                                }
                            }
                        }
                    }
                }
                .type{
                    padding: 20px 0;
                }
                .page{
                    text-align: center;
                    padding: 20px 0;
                }
            }
        }
    }
</style>